package com.zf.multilang.controller;


import com.zf.multilang.entity.ErrorInfo;
import com.zf.multilang.entity.UserInfo;
import com.zf.multilang.utils.MessageUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试获取多语言信息
 */
@RestController
@RequestMapping("/msg")
public class MessageController {

    @GetMapping("/getUserInfo")
    public UserInfo getUserInfo() {
        UserInfo res = new UserInfo();
        String message = MessageUtils.getMessage("login.zhangsan", new Object[]{"好人"}, "默认没找到，{0}");
        res.setUsername(message);
        return res;
    }

    @GetMapping("/getErrorInfo")
    public ErrorInfo getErrorInfo() {
        ErrorInfo res = new ErrorInfo();
        String message = MessageUtils.getMessage("error.10001", new Object[]{"666"}, "默认无数，{0}");
        res.setMsg(message);
        return res;
    }
}
